package firstInterview;

import java.util.Scanner;

/**
 * @author le
 */
public class Test01
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String a = in.nextLine();
        String b = in.nextLine();
        int index = in.nextInt();
        int count = 0;
        int cmp = 0;
        char[] x = a.toCharArray();
        char[] y = b.toCharArray();

        while(cmp < y.length){
            if (x[index] == y[cmp]){
                cmp++;
            }else{
                index++;
                count++;
            }



        }
        System.out.println(count);

    }
}
